`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    23:31:46 07/16/2017 
// Design Name: 
// Module Name:    id_fsm 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module id_fsm(
    input [7:0] char,
	 input clk,
    output reg out = 0
    );
	 reg [7:0] buffer [127:0];
	 reg [31:0] pt = 0;
	 reg [31:0] state = 0;
	 
	 integer i;
	 
	 always @(posedge clk) begin
		case (state)
			0:	
			begin
				if (char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char == "_") begin
					state <= 1;
					out <= 1;
					buffer[pt] <= char;
					pt <= pt+1;
				end
			end
			1:	
			begin
				if (char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char == "_" || char >= "0" && char <= "9") begin
					state <= 1;
					out <= 1;
					buffer[pt] <= char;
					pt <= pt+1;
				end
				else begin
					state <= 0;
					out <= 0;
					for (i = 0;i < pt;i = i+1) begin
						$display("%s", buffer[i]);
					end
					$display("/");
					pt <= 0;
				end
			end
		endcase
	 end

endmodule
